package com.example.swordjava;


import java.util.HashMap;
import java.util.Map;

public class Test53 {

    public static void main(String[] args) {

        int[][] a = {{1, 2, 3, 4},
                {5, 6, 7, 8},
                {9, 10, 11, 12},
                {13, 14, 15, 16}};

        System.out.println(Math.pow(1, 10));

    }

    public class ListNode {
        int val;
        ListNode next = null;

        ListNode(int val) {
            this.val = val;
        }
    }

    /**
     * 数字在升序数组中出现的次数
     * 给定一个长度为 n 的非降序数组和一个非负数整数 k ，要求统计 k 在数组中出现的次数
     */

    public int GetNumberOfK(int [] array, int k) {
        return helper(array, k + 0.5) - helper(array, k - 0.5);
    }

    public int helper(int[] array, double k) {
        int left = 0;
        int right = array.length - 1;
        while (left <= right) {
            int mid = (left + right) / 2;
            if (array[mid] <= k) {
                left = mid + 1;
            } else {
                right = mid - 1;
            }
        }
        return left;
    }

}














